package org.senseframework.support.orm.mybatis.definition;

import org.apache.commons.lang3.StringUtils;

/**
 * Author lanjian
 * Email  jianlan@iflytek.com
 */
public class Order {
    private String propertyName;
    private OrderBy orderBy;
    private String tableAs;


    @Override
    public String toString() {
        if (StringUtils.isBlank(tableAs)) {
            return propertyName + "  " + orderBy.name();
        }
        return tableAs + "." + propertyName + "  " + orderBy.name();
    }

    public Order(String propertyName, OrderBy orderBy, String tableAs) {
        this.propertyName = propertyName;
        this.orderBy = orderBy;
        this.tableAs = tableAs;
    }

    public String getPropertyName() {
        return propertyName;
    }

    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName;
    }

    public OrderBy getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(OrderBy orderBy) {
        this.orderBy = orderBy;
    }

    public String getTableAs() {
        return tableAs;
    }

    public void setTableAs(String tableAs) {
        this.tableAs = tableAs;
    }
}
